package com.downbox.controller;

import com.downbox.dto.R;
import com.downbox.dto.SaveMoodsReq;
import com.downbox.security.UserContext;
import com.downbox.service.MoodService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 情绪控制器
 */
@RestController
@RequestMapping("/mood")
@Tag(name = "情绪相关接口")
public class MoodController {

    @Autowired
    private MoodService moodService;

    @GetMapping("/options")
    @Operation(summary = "获取情绪选项列表")
    public R<List<String>> getMoodOptions() {
        List<String> options = moodService.getMoodOptions();
        return R.success(options);
    }

    @PostMapping("/save")
    @Operation(summary = "保存用户情绪")
    public R<Void> saveUserMoods(@Valid @RequestBody SaveMoodsReq req) {
        Long userId = UserContext.getUserId();
        moodService.saveUserMoods(userId, req);
        return R.success();
    }

    @GetMapping("/today")
    @Operation(summary = "获取用户今日情绪")
    public R<List<String>> getUserTodayMoods() {
        Long userId = UserContext.getUserId();
        List<String> moods = moodService.getUserTodayMoods(userId);
        return R.success(moods);
    }
}